<template>
  <view>
    <u-toast ref="uToast"></u-toast>
    <scroll-view class=" " scroll-y>
      <view class="u-margin-20">
        <view class="u-font-15"> 基本信息 </view>
        <view class="content u-m-t-20">
          <view class="u-padding-20">
            <view class="flex justify-between u-margin-top-20">
              <view class=""> 代理商名称 </view>
              <view class="">
                {{ agentInfoDo.userName }}
              </view>
            </view>
            <view class="flex justify-between u-margin-top-20">
              <view class=""> 代理商编号 </view>
              <view class="">
                {{ agentInfoDo.agentNo }}
              </view>
            </view>
            <view class="flex justify-between u-margin-top-20">
              <view class=""> 代理商类型 </view>
              <view class="">
                {{ agentInfoDo.userRole == 'ORG' ? '机构' : '代理商' }}
              </view>
            </view>

            <view class="flex justify-between u-margin-top-20">
              <view class=""> 联系电话 </view>
              <view class="">
                {{ agentInfoDo.mobileNo }}
              </view>
            </view>

            <view class="flex justify-between u-margin-top-20">
              <view class=""> 地址 </view>
              <view class="">
                {{ agentInfoDo.address }}
              </view>
            </view>

            <view class="flex justify-between u-margin-top-20">
              <view class=""> 申请时间 </view>
              <view class="">
                {{ agentInfoDo.createTime }}
              </view>
            </view>
          </view>
        </view>
        <view class="u-font-15 u-margin-top-30"> 证件信息 </view>
        <view class="content u-m-t-20 u-padding-20">
          <view class="flex justify-between u-margin-top-20">
            <view class=""> 姓名 </view>
            <view class="">
              {{ settleInfoDo.accountName }}
            </view>
          </view>
          <view class="flex justify-between u-margin-top-20">
            <view class=""> 身份证 </view>
            <view class="">
              {{
                settleInfoDo.accountIdCard &&
                hideCodeFn(settleInfoDo.accountIdCard)
              }}
            </view>
            <!-- <view class="">
              {{
                settleInfoDo.accountIdCard.substring(0, 1) +
                '****************' +
                settleInfoDo.accountIdCard.substring(
                  settleInfoDo.accountIdCard.length - 1
                )
              }}
            </view> -->
          </view>
          <view class="flex justify-between u-margin-top-20">
            <view class=""> 银行卡号 </view>
            <view class="">
              {{
                settleInfoDo.accountNo && hideBankCard(settleInfoDo.accountNo)
              }}
            </view>
            <!-- <view class="">
              {{
                settleInfoDo.accountNo.substring(0, 2) +
                '************' +
                settleInfoDo.accountNo.substring(
                  settleInfoDo.accountNo.length - 2
                )
              }}
            </view> -->
          </view>
        </view>
        <view class="u-font-15 u-margin-top-30"> 成本配置 </view>
        <view class="content u-m-t-20 u-padding-20">
          <view class="flex justify-between u-margin-top-20">
            <view class=""> 分润代付开关 </view>
            <view class="">
              {{ agentInfoDo.profitSwitch == '1' ? '开启' : '关闭' }}
            </view>
          </view>
          <view class="flex justify-between u-margin-top-20">
            <view class=""> 返现代付开关 </view>
            <view class="">
              {{ agentInfoDo.cashbackSwitch == '1' ? '开启' : '关闭' }}
            </view>
          </view>
          <view class="flex justify-between u-margin-top-20" @click="goCost()">
            <view class=""> 成本配置 </view>
            <view class="">
              查看详情
              <u-icon name="arrow-right" color="#333333" size="28"></u-icon>
            </view>
          </view>
          <view
            class="flex justify-between u-margin-top-20"
            @click="goReturn()"
          >
            <view class=""> 返现配置 </view>
            <view class="">
              查看详情
              <u-icon name="arrow-right" color="#333333" size="28"></u-icon>
            </view>
          </view>
        </view>
      </view>
    </scroll-view>
  </view>
</template>

<script>
export default {
  props: {
    // 声明你需要的属性
    agentNo: String,
  },
  data() {
    return {
      data: {},
      agentInfoDo: {},
      settleInfoDo: {},
      agentActivityInfoVos: [],
      agentPolicyCostInfo: [],
    };
  },
  mounted() {
    this.getAgentDetail();
  },
  methods: {
    // 成本配置
    goCost() {
      this.$u.route({
        url: 'pages/main/agent/agentCostAllocationDetailPerson',
        params: {
          agentPolicyCostInfo: encodeURIComponent(
            JSON.stringify(this.agentPolicyCostInfo)
          ),
        },
      });
    },
    // 返现配置
    goReturn() {
      this.$u.route({
        url: 'pages/main/agent/agentAddReappearanceAllocationMoneyPerson',
        params: {
          agentPolicyCostInfo: encodeURIComponent(
            JSON.stringify(this.agentActivityInfoVos)
          ),
        },
      });
    },
    getAgentDetail() {
      const _that = this;
      _that.$zx.user_api
        .getAgentDetail(_that.agentNo, 'detail')
        .then((data) => {
          console.log('getAgentDetail----->161', data);
          _that.agentInfoDo = data.agentInfoDo;
          _that.settleInfoDo = data.settleInfoDo;
          _that.agentActivityInfoVos = data.agentActivityInfoVos;
          _that.agentPolicyCostInfo = data.agentPolicyCostInfo;
        });
    },
    // 正则脱敏身份证
    hideCodeFn(IDCode) {
      return IDCode.replace(/(\d{2})(\d{14})(\d{2})/, '$1**************$3');
    },
    hideBankCard(IDCode) {
      return IDCode.replace(/(\d{2})(\d{14})(\d{2})/, '$1**************$3');
    },
  },
};
</script>

<style lang="scss" scoped>
.title {
  height: 80rpx;
  line-height: 80rpx;
  background-color: #e3eef6;
  color: #9d60ff;
}

.content {
  background-color: white;
  border-radius: 20rpx;
}

.color {
  color: #9d60ff;
}
</style>
